<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopStore extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */

    public function change()
    {
        $table = $this->table('shop_store',['engine'=>'InnoDB'])->setComment('商城-门店表');
        $table->addColumn(Column::string('name',50)->setNullable()->setComment('门店名称'));
        $table->addColumn(Column::char('phone',20)->setNullable()->setComment('手机号码'));
        $table->addColumn(Column::string('logo',500)->setNullable()->setComment('门店logo'));
        $table->addColumn(Column::string('contract_img',500)->setNullable()->setComment('签约合同'));
        $table->addColumn(Column::decimal('store_area',7,2)->setDefault(50)->setComment('门店面积'));
        $table->addColumn(Column::integer('devices_number')->setDefault(1)->setComment('设备数量'));
        $table->addColumn(Column::string('province',100)->setNullable()->setComment('省份'));
        $table->addColumn(Column::string('city',100)->setNullable()->setComment('城市'));
        $table->addColumn(Column::string('area',100)->setNullable()->setComment('地区'));
        $table->addColumn(Column::string('address',100)->setNullable()->setComment('详情地址'));
        $table->addColumn(Column::string('start_time',100)->setNullable()->setComment('营业开始时间'));
        $table->addColumn(Column::string('end_time',100)->setNullable()->setComment('营业结束时间'));
        $table->addColumn(Column::string('longitude',255)->setNullable()->setComment('经度'));
        $table->addColumn(Column::string('latitude',100)->setNullable()->setComment('纬度'));
        $table->addColumn(Column::string('remark',100)->setNullable()->setComment('备注'));
        $table->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序'));
        $table->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态(0:禁用,1:启用)'));
        $table->addColumn(Column::tinyInteger('is_deleted')->setDefault(0)->setComment('删除(1:删除,0:未删)'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
